package org.goyo.common.utils;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ToolUtils {
	
	/**
	 * 获得uuid数组
	 * @param list
	 * @return
	 */
	public static Set<String>  getFiles(List<?> list,String fileName){
		if(list.size() < 1)
			return null;
		Set<String> set = new HashSet<String>();
		for(int i=0;i<list.size();i++){
			try {
				fileName = fileName.replaceFirst(fileName.substring(0, 1), fileName.substring(0, 1).toUpperCase());
				set.add((String)list.get(i).getClass().getMethod("get"+fileName).invoke(list.get(i)));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return set;
	}
	
	/**
	 * 返回in参数
	 * 
	 * @author chenchuan
	 * 2014年12月9日
	 */
	public static StringBuffer getInParamter(Object[] strs){
		StringBuffer buf = new StringBuffer("( ");
		if(strs != null){
			for(int i=0;i<strs.length;i++){
				if(i==strs.length -1)
					buf.append("'"+strs[i]+"'");
				else
					buf.append("'"+strs[i]+"' ,");
			}
		}else{
			buf.append("'--------'");
		}
		
		buf.append(" )");
		return buf;
	}
	
	public static String addBillNumber(String number,String bizType){
		String billNumber = null;
		String seqNum = String.valueOf(Integer.parseInt(number.substring(bizType.length()+8))+1);
		String num = number.substring(0, bizType.length()+8);
		String seq = seqNum;
		for(int i=0;i<6-seq.length();i++){
			seqNum = "0"+seqNum;
		}
		billNumber = num + seqNum;
		
		return billNumber;
	}
	
	public static String addBaseNumber(String number,String bizType){
		String billNumber = null;
		String seqNum = String.valueOf(Integer.parseInt(number.substring(bizType.length()))+1);
		String num = number.substring(0, bizType.length());
		String seq = seqNum;
		for(int i=0;i<6-seq.length();i++){
			seqNum = "0"+seqNum;
		}
		billNumber = num + seqNum;
		
		return billNumber;
	}
	
}
